package com.yueya.auth.config;


import org.springframework.boot.context.properties.ConfigurationProperties;

import static com.yueya.auth.config.AuthConstant.APP_TYPE_SERVER;
import static com.yueya.auth.config.AuthConstant.AUTH_MODE_JWT;
import static com.yueya.auth.config.AuthConstant.AUTH_MODE_NORMAL;

@ConfigurationProperties(prefix = "auth")
public class AuthProperties {
    /**
     * 是否启用auth
     */
    private boolean enable = true;
    /**
     * 默认拦截
     */
    private String adminPath=null;
    /**
     * 默认不拦截
     */

    private String frontPath=null;

    private String successUrl=null;

    private String type=null;
    /**
     * 应用标识
     */
    private String appId=null;
    /**
     * 认证的模式：normal/jwt/sso 默认是normal
     */
    private String mode = AUTH_MODE_NORMAL;


    public boolean isServer() {
        return APP_TYPE_SERVER.equals(getType());
    }
    /**
     * jwt 公钥
     */
    private String publicKey;
    /**
     * jwt 私钥
     */
    private String privateKey;

    /**
     * 登录过期时间. 单位 s
     */
    private int expireTime = 600;

    /**
     * 加密方式 默认HS256，可设置为RS256非对称加密
     */
    private  String signMode = "HS256";
    /**
     * 对称加密模式的秘钥
     */
    private String secretKey;
    /**
     * jwt refreshToken 过期时间 单位，hour
     */
    private int refreshTime = 7*24;

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }
    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    public String loginUrl=null;
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


    public  String getAdminPath() {
        return adminPath;
    }

    public  void setAdminPath(String adminPath) {
        this.adminPath = adminPath;
    }

    public  String getFrontPath() {
        return frontPath;
    }

    public  void setFrontPath(String frontPath) {
        this.frontPath = frontPath;
    }

    public  String getSuccessUrl() {
        return successUrl;
    }

    public  void setSuccessUrl(String successUrl) {
        this.successUrl = successUrl;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public int getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(int expireTime) {
        this.expireTime = expireTime;
    }

    public int getRefreshTime() {
        return refreshTime;
    }

    public void setRefreshTime(int refreshTime) {
        this.refreshTime = refreshTime;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public boolean isJwtMode() {
        return AUTH_MODE_JWT.equals(this.mode);
    }

    public String getSignMode() {
        return signMode;
    }

    public void setSignMode(String signMode) {
        this.signMode = signMode;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }
}
